
/**
 * 使用方法
 * bbar : new Ext.PagingToolbar({   
    pageSize : pagesize,   
    displayInfo : true,   
    emptyMsg : '没有找到相关数据',   
    store : store,   
    plugins : [new Ext.ux.PageSizePlugin()]   
  })  
  
 * 
 */
Ext.namespace('Ext.ux');   
  
Ext.ux.PageSizePlugin = function() {   
    Ext.ux.PageSizePlugin.superclass.constructor.call(this, {   
        store: new Ext.data.SimpleStore({   
            fields: ['text', 'value'],   
            data: [['10', 10], ['20', 20], ['30', 30], ['50', 50], ['100', 100]]   
        }),   
        xtype:'combo',
        mode: 'local',   
        displayField: 'text',   
        valueField: 'value',   
        editable: true,   
        allowBlank: false,  
        blankText:'请输入数字',
        regex:/^\d+$/,//正则表达式在/...../之间. [\u4e00-\u9fa5] : 只能输入中文.
        regexText:'请输入数字',
        triggerAction: 'all',   
        width: 60,
        enableKeyEvents :true
    });   
};   
  
Ext.extend(Ext.ux.PageSizePlugin, Ext.form.ComboBox, {   
    init: function(paging) {   
        paging.on('render', this.onInitView, this);   
    },   
       
    onInitView: function(paging) {   
        paging.add('-',   
            this,   
            '条/页'  
        );   
        this.setValue(paging.pageSize);   
        this.on('select', this.onPageSizeChanged, paging); 
        this.on('keypress', function(combo,e){
        	//alert(e.getKey());
        	if(e.getKey()==13&&combo.isValid()){  //回车   
                this.pageSize = parseInt(combo.getRawValue());   
		        compage = parseInt(combo.getValue());   
		        this.doLoad(0);                                    
             }  
        },paging); 
    },        
    onPageSizeChanged: function(combo) {   
        this.pageSize = parseInt(combo.getValue());   
        compage = parseInt(combo.getValue());   
        this.doLoad(0);   
    }   
});  
